package com.echo.codec;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;
import java.util.Map;

public class MapEncoder extends MessageToMessageEncoder<Map<String,String>> {
    @Override
    protected void encode(ChannelHandlerContext ctx, Map<String,String> msg, List<Object> out) throws Exception {
        out.add(new ObjectMapper().writeValueAsString(msg));
    }
}
